# -*- coding: utf-8 -*-
# 创建时间：2021/7/17 10:57
from bs4 import BeautifulSoup
import requests
import time, math, random, json
import pymysql
import re

__author__ = 'LuckyHhy'
#re.match #从开始位置开始匹配，如果开头没有则无
#re.search #搜索整个字符串
#re.findall #搜索整个字符串，返回一个list

def main():
    # 用逗号分隔
    ss=re.split(r'[\s\,]+', 'a,b, c  d')
    print(ss) #['a', 'b', 'c', 'd']
    # 用空格分割
    print(re.split(r'\s+', 'a b   c')) #['a', 'b', 'c']

    ks=re.search(r'[a-z]+', 'liuyaN1234ab9').group()
    print(ks)

    #对大小写不敏感
    df=re.search(r'[a-z]+', 'liuyaN1234ab9', re.I).group()  # 返回'liuyaN'，
    print(df)

    dd=re.match(r'l', 'liuyan1').group()  # 返回l
    print(dd)

    s = '111,222,aaa,bbb,ccc333,444ddd'
    rule = r'[a-z]+'
    c_r=re.compile(rule)
    print(c_r.findall(s))

if __name__ == '__main__':
    main()
